package PTA_05_08;

import java.util.ArrayList;
import java.util.Scanner;

public class Main1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int type = sc.nextInt();
        switch (type) {
            case 1:
                test1(sc);
                break;
            case 2:
                test2(sc);
                break;
            case 3:
                test3(sc);
                break;
            case 4:
                test4(sc);
        }
    }

    //test方法为（4）中情况，见上述说明
    public static void test1(Scanner sc) {
        Student stu1 = new Student();
        Student stu2 = new Student();
        System.out.println("学生总数为：" + stu2.getStuNum());
    }

    public static void test2(Scanner sc) {
        Course c1 = new Course();
        Course c2 = new Course();
        Course c3 = new Course();
        System.out.println("课程总数为：" + c3.getcNum());
    }

    public static void test3(Scanner sc) {
        Student stu1 = new Student(sc.next(), sc.next());
        Course c1 = new Course();
        Course c2 = new Course();
        c1.setcID("c01");
        c1.setcName("数据结构");
        c2.setcID("c02");
        c2.setcName("软件工程");

        Schedule schedule = new Schedule();
        schedule.addCourse(stu1, c1);
        schedule.addCourse(stu1, c2);

        System.out.println("学生选课的总数为：" + schedule.getSchNum());
        System.out.println("学生选课情况如下：");
        schedule.displayCourse();
    }


    public static void test4(Scanner sc) {
        Student stu1 = new Student(sc.next(), sc.next());
        Student stu2 = new Student(sc.next(), sc.next());
        Student stu3 = new Student(sc.next(), sc.next());

        Course c1 = new Course(sc.next(), sc.next());
        Course c2 = new Course(sc.next(), sc.next());
        Course c3 = new Course(sc.next(), sc.next());
        Course c4 = new Course(sc.next(), sc.next());

        Schedule schedule = new Schedule();

        schedule.addCourse(stu1, c2);
        schedule.addCourse(stu1, c3);
        schedule.addCourse(stu2, c1);
        schedule.addCourse(stu3, c1);
        schedule.addCourse(stu3, c2);
        schedule.addCourse(stu3, c4);

        System.out.println("学生总数为：" + stu3.getStuNum());
        System.out.println("课程总数为：" + c4.getcNum());
        System.out.println("学生选课的总数为：" + schedule.getSchNum());
        System.out.println("学生选课情况如下：");
        schedule.displayCourse();
    }
}

// 学生类Student
class Student {
    static int stuNum = 0;
    String stuID;
    String stuName;

    public Student() {
        System.out.println("学生类无参构造方法");
        stuNum++;
    }

    public Student(String stuID, String stuName) {
        this.stuID = stuID;
        this.stuName = stuName;
        stuNum++;
        System.out.println("学生类有参构造方法");
    }

    public String getStuID() {
        return stuID;
    }

    public void setStuID(String stuID) {
        this.stuID = stuID;
    }

    public String getStuName() {
        return stuName;
    }

    public void setStuName(String stuName) {
        this.stuName = stuName;
    }

    public int getStuNum() {
        return stuNum;
    }


    public void RstuID(String stuID)//修改ID
    {
        setStuID("stuID");
    }

    public void RstuName(String stuName)//修改姓名
    {
        setStuName("stuName");
    }
}

// 课程类Course
class Course {
    static int cNum = 0;
    String cID;
    String cName;

    public Course() {
        System.out.println("课程类无参构造方法");
        cNum++;
    }

    public Course(String cID, String cName) {
        this.cID = cID;
        this.cName = cName;
        cNum++;
        System.out.println("课程类有参构造方法");
    }

    public String getcID() {
        return cID;
    }

    public void setcID(String cID) {
        this.cID = cID;
    }

    public String getcName() {
        return cName;
    }

    public void setcName(String cName) {
        this.cName = cName;
    }

    public int getcNum() {
        return cNum;
    }

    public void RcID(String cID)//修改ID
    {
        setcID(cID);
    }

    public void RcName(String cName)//修改名称
    {
        setcName(cName);
    }
}

// 学生选课类Schedule
class Schedule {
    static int schNum = 0;
    private ArrayList<Student> stuList;
    private ArrayList<Course> cList;


    public Schedule() {
        stuList = new ArrayList<>();
        cList = new ArrayList<>();
    }

    public void addCourse(Student stu, Course course) {
        schNum++;
        stuList.add(stu);
        cList.add(course);
    }

    public int getSchNum() {
        return schNum;
    }

    public void displayCourse() {
        for (int i = 0; i < stuList.size(); i++) {
            if (i < stuList.size() - 1)
                System.out.println(stuList.get(i).getStuID() + "\t" + stuList.get(i).stuName + "\t"
                        + cList.get(i).getcID() + "\t" + cList.get(i).getcName());
            else
                System.out.print(stuList.get(i).getStuID() + "\t" + stuList.get(i).stuName + "\t"
                        + cList.get(i).getcID() + "\t" + cList.get(i).getcName());
        }
    }
}